home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Chip 2007 January, February, March & April
/
Chip-Cover-CD-2007-02.iso
/
Pakiet bezpieczenstwa
/
mini Pentoo LiveCD 2006.1
/
mpentoo-2006.1.iso
/
livecd.squashfs
/
usr
/
lib
/
metasploit
/
src
/
impurity
/
shelldemo
/
misc.c
< prev
Wrap
C/C++ Source or Header
|
2006-06-30
|
891b
|
50 lines
/*
* Copyright (c) 2004-2005 vlad902 <vlad902 [at] gmail.com>
* This file is part of the Metasploit Framework.
* $Revision: 1.1 $
*/
#include <stdio.h>
#include <time.h>
#include <pwd.h>
#include <grp.h>
#include "cmd.h"
char * get_uid_str(int uid)
{
struct passwd * pwd;
static char id[20];
snprintf(id, sizeof(id), "%i", uid);
if((pwd = getpwuid(uid)) != NULL)
strncpy(id, pwd->pw_name, sizeof(id));
id[sizeof(id) - 1] = '\0';
return id;
}
char * get_gid_str(int gid)
{
struct group * grp;
static char id[10];
snprintf(id, sizeof(id), "%i", gid);
if((grp = getgrgid(gid)) != NULL)
strncpy(id, grp->gr_name, sizeof(id));
id[sizeof(id) - 1] = '\0';
return id;
}
char * get_time_str(char * format)
{
static char time_stamp[128];
time_t time_int;
time(&time_int);
strftime(time_stamp, sizeof(time_stamp), format, localtime(&time_int));
return time_stamp;
}